﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using TomanuExtensions;
using TomanuExtensions.Utils;

namespace AmiEmuLib.AmigaConfiguration.CoreConfig
{
    /// <summary>
    /// Only for comapatiblity with WinUAE.
    /// </summary>
    public class JIT : XmlBase
    {
        public bool Enabled;
        public bool NoFlags;
        public bool FPU;
        public bool FPUMoreCompatible;
        public bool HardFlush;
        public bool ConstJump;
        public int CacheSize;

        public JIT(XmlReader a_reader)
            : base(a_reader)
        {
        }

        protected override void ReadXml(XmlReader a_reader)
        {
            Enabled = a_reader.GetAttributeBool("Enabled");

            a_reader.ReadStartElement(GetType().Name);

            NoFlags = a_reader.ReadElementContentAsBoolean("NoFlags");
            FPU = a_reader.ReadElementContentAsBoolean("FPU");
            FPUMoreCompatible = a_reader.ReadElementContentAsBoolean("FPUMoreCompatible");
            HardFlush = a_reader.ReadElementContentAsBoolean("HardFlush");
            ConstJump = a_reader.ReadElementContentAsBoolean("ConstJump");
            CacheSize = a_reader.ReadElementContentAsInt("CacheSize");

            a_reader.ReadEndElement();
        }

        public override void WriteXml(XmlWriter a_writer)
        {
            a_writer.WriteStartElement(GetType().Name);

            a_writer.WriteAttribute("Enabled", Enabled);
            a_writer.WriteElement("NoFlags", NoFlags);
            a_writer.WriteElement("FPU", FPU);
            a_writer.WriteElement("FPUMoreCompatible", FPUMoreCompatible);
            a_writer.WriteElement("HardFlush", HardFlush);
            a_writer.WriteElement("ConstJump", ConstJump);
            a_writer.WriteElement("CacheSize", CacheSize);

            a_writer.WriteEndElement();
        }
    }
}
